package com.le.tester.javaThink.fifth.chapter13_FuncProgramming;

import java.util.function.Function;

/**
 * createTime：2021/8/6 16:22
 * description：柯里化部分求值
 */
public class CurryingAndPartials {
    //未柯里化；未将一个函数转换成多个函数
    static String uncurried(String a, String b) {
        return a + b;
    }

    public static void main(String[] args) {
        Function<String, Function<String, String>> sum = a -> b -> a + b;

        System.out.println(uncurried("Hi", "Ho"));

        Function<String, String> hi = sum.apply("Hi ");
        System.out.println(hi.apply("Ho"));

        //部分应用
        Function<String, String> hup = sum.apply("Hup ");
        System.out.println(hup.apply("Ho"));
        System.out.println(hup.apply("Hey"));
    }
}
